Completed
Push — master ( 90f02e...53fcb4 )
by Maxence
02:59
created

actions.changeLinkStatus   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
/*
2
 * Circles - Bring cloud-users closer together.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
/** global: OC */
27
/** global: OCA */
28
/** global: Notyf */
29
30
/** global: actions */
31
/** global: nav */
32
/** global: elements */
33
/** global: resultMembers */
34
/** global: resultCircles */
35
/** global: curr */
36
/** global: api */
37
38
39
var actions = {
40
41
42
	changeMemberLevel: function (member, level) {
43
		if (parseInt(level) === define.levelOwner) {
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
44
			actions.changeMemberOwner(member);
45
			return;
46
		}
47
		api.levelMember(curr.circle, member, level, resultMembers.levelMemberResult);
48
		nav.circlesActionReturn();
49
	},
50
51
52
	changeMemberOwner: function (member) {
53
		OC.dialogs.confirm(
54
			t('circles', 'Are you sure you want to transfer your Owner rights ?', [member]),
55
			t('circles', 'This action is irreversible'),
56
			function (e) {
57
				if (e === true) {
58
					api.levelMember(curr.circle, member, define.levelOwner,
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
59
						resultMembers.levelMemberResult);
60
					nav.circlesActionReturn();
61
					return;
62
				}
63
64
				nav.displayMembers('');
65
			});
66
	},
67
68
69
	changeMemberStatus: function (member, value) {
70
		if (value === 'remove_member' || value === 'dismiss_request') {
71
			api.removeMember(curr.circle, member, resultMembers.removeMemberResult);
72
		}
73
		if (value === 'accept_request') {
74
			api.addMember(curr.circle, member, resultMembers.addMemberResult);
75
		}
76
	},
77
78
79
	changeLinkStatus: function (link, value) {
80
		api.linkStatus(link, value, resultLinks.linkStatusResult);
0 ignored issues
show
Bug introduced by
The variable resultLinks seems to be never declared. If this is a global, consider adding a /** global: resultLinks */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
81
	},
82
83
84
	selectCircle: function (circle_id) {
85
		curr.searchUser = '';
86
		elements.addMember.val('');
87
		elements.linkCircle.val('');
88
89
		nav.circlesActionReturn();
90
		api.detailsCircle(circle_id, resultCircles.selectCircleResult);
91
	},
92
93
94
	unselectCircle: function (circle_id) {
95
		elements.mainUIMembersTable.emptyTable();
96
		elements.navigation.children(".circle[circle-id='" + circle_id + "']").remove();
97
		elements.emptyContent.show(800);
98
		elements.mainUI.fadeOut(800);
99
100
		curr.circle = 0;
101
		curr.circleLevel = 0;
102
	},
103
104
105
	saveSettings: function () {
106
		data = {
0 ignored issues
show
Bug introduced by
The variable data seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data.
Loading history...
107
			allow_links: (elements.settingsLink.is(":checked")),
108
			allow_links_auto: (elements.settingsLinkAuto.is(":checked")),
109
			allow_links_files: (elements.settingsLinkFiles.is(":checked"))
110
		};
111
112
		api.settingsCircle(curr.circle, data, settings.saveSettingsResult);
0 ignored issues
show
Bug introduced by
The variable settings seems to be never declared. If this is a global, consider adding a /** global: settings */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
113
	},
114
115
	/**
116
	 *
117
	 * @param search
118
	 */
119
	searchMembersRequest: function (search) {
120
121
		if (curr.searchUser === search) {
122
			return;
123
		}
124
125
		curr.searchUser = search;
126
127
		$.get(OC.linkToOCS('apps/files_sharing/api/v1', 1) + 'sharees',
128
			{
129
				format: 'json',
130
				search: search,
131
				perPage: 200,
132
				itemType: 'principals'
133
			}, resultMembers.searchMembersResult);
134
	},
135
136
137
	getStringTypeFromType: function (type) {
138
		switch (type) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
139
			case '1':
140
				return t('circles', 'Personal circle');
141
			case '2':
142
				return t('circles', 'Hidden circle');
143
			case '4':
144
				return t('circles', 'Private circle');
145
			case '8':
146
				return t('circles', 'Public circle');
147
		}
148
149
		return t('circles', 'Circle');
150
	},
151
152
153
	/**
154
	 *
155
	 */
156
	onEventNewCircle: function () {
157
		curr.circle = 0;
158
		curr.circleLevel = 0;
159
160
		elements.circlesList.children('div').removeClass('selected');
161
		elements.emptyContent.show(800);
162
		elements.mainUI.fadeOut(800);
163
	},
164
165
166
	/**
167
	 *
168
	 */
169
	onEventNewCircleName: function () {
170
		this.onEventNewCircle();
171
		nav.displayOptionsNewCircle((elements.newName.val() !== ''));
172
	},
173
174
175
	/**
176
	 *
177
	 */
178
	onEventNewCircleType: function () {
179
		this.onEventNewCircle();
180
		elements.newTypeDefinition.children('div').fadeOut(300);
181
		var selectedType = elements.newType.children('option:selected').val();
182
		if (selectedType === '') {
183
			elements.newType.addClass('select_none');
184
		}
185
		else {
186
			elements.newType.removeClass('select_none');
187
			$('#circles_new_type_' + selectedType).fadeIn(
188
				300);
189
		}
190
	}
191
192
193
};
194